package com.yyfax.ph.personal.entrydetail;

import com.yyfax.common.CLog;
import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.ph.base.YJPH;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

import java.util.List;

/**
 * 类描述： 获取进件明细
 */
public class EntryDetailModel extends Model {
	private static final String TAG = EntryDetailModel.class.getSimpleName();

	@Override
	public Observable getObservable(Object params, int functionalCode) {
		Service service = (Service) NetworkHelper.createService(Service.class);
		String token = YJPH.getInstance().getPreferenceManager().getLoginToken();
		return service.getEntryDetial(token, (EntryDetial) params);
	}

	@Override
	public void onNext(Object obj) {
		CLog.i(TAG, "onNext: " + obj.toString());
		EntryDetailResult result = (EntryDetailResult) obj;
		EventAgent.post(result);
	}


	public interface Service {
		@POST("apply/query/getSubDetailList")
		Observable<EntryDetailResult> getEntryDetial(@Header("token") String token, @Body EntryDetial applyList);
	}

	public static class EntryDetial {
		String subUserId;
		String pageNo;
		String pageSize;

		public EntryDetial(String subUserId, String pageNo, String pageSize) {
			this.subUserId = subUserId;
			this.pageNo = pageNo;
			this.pageSize = pageSize;
		}
	}

	public static class EntryDetailBean {
		public String id;
		public String name;
		public String rcmdTime;
		public String status;
	}

	public static class EntryDetailResult extends BaseResultEntity<List<EntryDetailBean>> {
	}
}
